<?php
/**
 * 核销人员管理
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019-03-28
 * Time: 下午 11:26
 */
namespace App;

use Endroid\QrCode\QrCode;
use Model\AfterPersonMod;
use Model\MemberMod;

class AfterPerson extends Action
{
    private $AfterPerson = null;
    private $Member = null;

	public function __construct()
	{
		parent::__construct();
		$this->AfterPerson = new AfterPersonMod();
	}

    /**
     * 核销员工列表
     */
	public function li()
    {
        $_list = $this->AfterPerson->findAll(array('activity_id'=>$this->_gpc['activity_id'],'status'=>$this->_gpc['status']),array('order'=>array('id','desc')),array('id','uid'));
        if(count($_list) > 0){
            foreach($_list as $_k=>$_v){
                $_member = $this->uidToInfo($_v['uid']);
                $_list[$_k]['name'] = $_member['nickname'];
                $_list[$_k]['header'] = $_member['avatar'];
            }
            $this->_result = array('status'=>'success','data'=>$_list);
        }
        $this->result($this->_result);
    }

    /**
     * 获取添加员工的二维码
     */
    public function addQrcode()
    {
        $_url = urldecode(murl('entry//iscan',array('m'=>'kuyuan_vbz','activity_id'=>$this->_gpc['activity_id'],'type'=>'adminAfterApply'),true,true));
        $_qrcode = parent::getQrcode('add_after_person_qrcode',$this->_gpc['activity_id'],$_url,true);
        if($_qrcode){
            $this->_result = array('status'=>'success','data'=>$_qrcode);
        }
        $this->result($this->_result);
    }

    /**
     * 核销人员通过审核
     */
    public function passAfterPerson()
    {
        if($this->AfterPerson->update(array('status'=>1),array('id'=>$this->_gpc['person_id']))){
            $this->_result = array('status'=>'success');
        }
        $this->result($this->_result);
    }

    /**
     * 删除活动核销人员
     */
    public function deleteAfterPerson()
    {
        if($this->AfterPerson->update(array('status'=>9),array('id'=>$this->_gpc['person_id']))){
            $this->_result = array('status'=>'success');
        }
        $this->result($this->_result);
    }
}